package com.yellow.orderservice.controller;

import com.yellow.orderservice.entity.Order;
import com.yellow.orderservice.entity.Sender;
import com.yellow.orderservice.service.SenderService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: hy
 * @create: 2024-04-25
 */

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/sender")
@Slf4j
public class SenderController {

    @Resource
    private SenderService senderService;
    @RequestMapping("/getSenderByName/{name}")
    public List<Sender> getSenderByName(@PathVariable("name") String name){
        return senderService.findSenderByName(name);
    }


    @RequestMapping("/getOrdersBySenderName/{name}")
    public List<Order> getOrdersBySenderName(@PathVariable(value = "name") String name){
        return senderService.getOrdersBySenderName(name);
    }
}
